package site.luojie.framework.util;

/**
 * @Description:
 * @Author jie.luo
 * @Create: 2020-05-06 00:57
 **/
public class StringUtil {

    /**
     * 首字母小写
     */
    public static String toLowerCaseFirstChar(String str) {
        if (Character.isLowerCase(str.charAt(0))) {
            return str;
        }
        return (new StringBuilder())
                .append(Character.toLowerCase(str.charAt(0)))
                .append(str.substring(1)).toString();
    }

    /**
     * 首字母大写
     */
    public static String toUpperCaseFirstChar(String str) {
        if (Character.isUpperCase(str.charAt(0))) {
            return str;
        }
        return (new StringBuilder())
                .append(Character.toUpperCase(str.charAt(0)))
                .append(str.substring(1)).toString();
    }

    public static void main(String[] args) {
        System.out.println(toLowerCaseFirstChar("A"));
        System.out.println(toLowerCaseFirstChar("AB"));
        System.out.println(toLowerCaseFirstChar("a"));
        System.out.println(toLowerCaseFirstChar("aB"));
    }

}
